const merge = require('webpack-merge')
const path = require('path')

let baseConfig = {
  configureWebpack: {
    resolve: {
      alias: {
        '@api': path.resolve('src' + path.sep + 'api'),
        '@views': path.resolve('src' + path.sep + 'views'),
        '@com': path.resolve('src' + path.sep + 'components'),
        '@utils': path.resolve('src' + path.sep + 'utils'),
        '@assets': path.resolve('src' + path.sep + 'assets')
      }
    }
  }
}



const devConfig = {
  devServer: {
    // open: true,
    host: 'localhost',
    port: 8082,
    https: false, // 开启https代理
    hotOnly: false, // 热模块更新作用
    proxy: {
      '/rc': {
        // target: 'http://10.49.6.63:8080', // local test
        // target: 'http://10.49.12.49:8080',
        // target: 'http://dip.cnsuning.com/service/1554195600016/3.0',
        // target: 'http://bdopssit.cnsuning.com',
        target: 'http://localhost:8080',
        changeOrigin: true,
        logLevel: 'debug',
      },
      '/dip': {
        // target: 'http://10.49.6.63:8080', // local test
        // target: 'http://10.49.12.49:8080',
        // target: 'http://dip.cnsuning.com/service/1554195600016/3.0',
        // target: 'http://bdopssit.cnsuning.com',
        // target: 'http://bdopssit.cnsuning.com',
        target: 'http://bdopstest1.cnsuning.com:8080',
        changeOrigin: true,
        pathRewrite: {
          '^/dip': '/'
        }
        // logLevel: 'debug',
      }
    }
  }
}


const proConfig = {
  configureWebpack: {
    plugins: []
  }
}
if (process.env.NODE_ENV === 'development') {
  baseConfig = merge(baseConfig, devConfig)
} else if (process.env.NODE_ENV === 'production') {
  baseConfig = merge(baseConfig, proConfig)
}
module.exports = baseConfig
